<html>
<!-- =====================================================================

  File:      [StoreServerComponents].htm for Adventure Works Cycles Storefront Sample
  Summary:   Self-documentation for application
  Date:	     August 12, 2003

=====================================================================

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= -->
    <head>
        <title>Adventure Works Cycles Store Documentation</title>
        <link rel="stylesheet" href="style.css">
    </head>
    <body>
        <h1>"CurrencyType and ConversionFunction" Assemblies</h1>

        <b>Description:</b>

        <P>Microsoft SQL Server 2005 can store managed assemblies.  The script below adds two managed assemblies
           which contains the <a href="Currency_cs.htm">Currency</a>&nbsp; class and the <a href="CurrencyConverter_cs.htm">ConvertCurrency</a>
           method.  The first assembly exposes the class as the <a href="Currency.htm">Currency</a> user defined type,
           and second assembly exposes the method as the <a href="DBO.ConvertCurrency.htm">ConvertCurrency</a> scalar user defined function in
           the Adventure Works Cycles database.  Two assemblies are used in order to minimize the
impact of changing the definition of the function when the type does not change.  This would be especially true if the UDT were used as a column in the database.</P>

        <b>Definition:</b>

<pre style="background-color:white">
<span style="color: #0000FF"><strong>CREATE</strong></span> <span style="color: #0000FF"><strong>ASSEMBLY</strong></span> [CurrencyType] <span style="color: #0000FF"><strong>FROM</strong></span> @SamplesPath <span style="color: #4444FF">+</span> <span style="color: #444444">'AdventureWorks\CS\CurrencyType\bin\debug\CurrencyType.dll'</span>
with permission_set <span style="color: #4444FF">=</span> safe;


<span style="color: #008000">-- These aid in debugging if you detach the database and move it elsewhere</span>
<span style="color: #0000FF"><strong>ALTER</strong></span> <span style="color: #0000FF"><strong>ASSEMBLY</strong></span> [CurrencyType] <span style="color: #0000FF"><strong>ADD</strong></span> FILE <span style="color: #0000FF"><strong>FROM</strong></span> @SamplesPath <span style="color: #4444FF">+</span> <span style="color: #444444">'AdventureWorks\CS\CurrencyType\bin\debug\CurrencyType.pdb'</span>;
<span style="color: #0000FF"><strong>ALTER</strong></span> <span style="color: #0000FF"><strong>ASSEMBLY</strong></span> [CurrencyType] <span style="color: #0000FF"><strong>ADD</strong></span> FILE <span style="color: #0000FF"><strong>FROM</strong></span> @SamplesPath <span style="color: #4444FF">+</span> <span style="color: #444444">'AdventureWorks\CS\CurrencyType\Currency.cs'</span>;

<span style="color: #0000FF"><strong>CREATE</strong></span> <span style="color: #0000FF"><strong>ASSEMBLY</strong></span> [ConversionFunction] <span style="color: #0000FF"><strong>FROM</strong></span> @SamplesPath <span style="color: #4444FF">+</span> <span style="color: #444444">'AdventureWorks\CS\ConversionFunction\bin\debug\ConversionFunction.dll'</span>
with permission_set <span style="color: #4444FF">=</span> unsafe;


<span style="color: #008000">-- These aid in debugging if you detach the database and move it elsewhere</span>
<span style="color: #0000FF"><strong>ALTER</strong></span> <span style="color: #0000FF"><strong>ASSEMBLY</strong></span> [ConversionFunction] <span style="color: #0000FF"><strong>ADD</strong></span> FILE <span style="color: #0000FF"><strong>FROM</strong></span> @SamplesPath <span style="color: #4444FF">+</span> <span style="color: #444444">'AdventureWorks\CS\ConversionFunction\bin\debug\ConversionFunction.pdb'</span>;
<span style="color: #0000FF"><strong>ALTER</strong></span> <span style="color: #0000FF"><strong>ASSEMBLY</strong></span> [ConversionFunction] <span style="color: #0000FF"><strong>ADD</strong></span> FILE <span style="color: #0000FF"><strong>FROM</strong></span> @SamplesPath <span style="color: #4444FF">+</span> <span style="color: #444444">'AdventureWorks\CS\ConversionFunction\CurrencyConverter.cs'</span>;

</pre>

    </body>
</html>
